#!/bin/bash

SCRIPT_DIR="/remote/iosg/data/etc/general_operations/deploy/bot-coin/research_instrument_cache/coin"
cd ${SCRIPT_DIR}

START_DATE="$(date --date='2 day ago' '+%Y%m%d')"
END_DATE=$(date +%Y%m%d -d "${START_DATE} + 1 day")
if [ -n "${1}" ]; then
  START_DATE="${1}"
  END_DATE=$(date +%Y%m%d -d "${START_DATE} + 1 day")
fi
if [ -n "${2}" ]; then
  END_DATE="${2}"
fi

source /remote/iosg/home/bot-coin/miniconda3/etc/profile.d/conda.sh
conda activate /remote/iosg/home/bot-coin/miniconda3/envs/coin_env
cd python

srun -n1 ./pyrunner coin/support/feed_tool/feed_cache/app/instrument_cache_builder.py \
  --start_date=${START_DATE} \
  --end_date=${END_DATE} \
  --machine=feed-02.ap-northeast-1.aws \
  --static_cache_root=/remote/iosg/coin/cache/prod

conda deactivate
